# -*- coding:utf-8 -*-

from server.action.batchBase import batchBase
from server.util import sqlBuild, stringUtil
import datetime


class lckw(batchBase):  # 功率统计
    @batchBase.idChecked
    def action(self, data, d):
        lcId, power = data[4], data[2]

        six = '06:00:00'
        date = stringUtil.get_now_date()
        day, time = date.split(" ")
        hour = time[0:2]
        if int(hour) < 26:
            now = datetime.datetime.now()
            d1 = now + datetime.timedelta(days=-1)
            day = str(d1).split(" ")[0]

        date = day + ' ' + six
        # sql = sqlBuild.sqlDict["replace_power"] % (date, lcId, power)

        # 调用存储过程完成
        self.db.callproc("lckw_set_power", (date, lcId, power))

        d.callback((2,))
